<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <title>XLLoop - An Example Lisp Function Handler</title>
        <link rel="shortcut icon" href="favicon.ico" type="image/vnd.microsoft.icon"/>
        <link rel="stylesheet" href="style.css" type="text/css" />
        <meta name="description" content="Excel Addin Framework for Java"/>
        <meta name="keywords" content="java, excel, addin, xll, xloper"/>
        <meta http-equiv="pragma" content="no-cache"/>    
    </head>

    <body>

    <div id="heading">
        <div class="title"><a href="index.html"><img border="0" src="logo.gif"/></a>XLLoop</div>
        <div class="subtitle">An Example Lisp Function Handler</div>
    </div>
    
    <div class="content">
        <div class="section">
            <div class="section-title">About</div>
            <div class="section-content">
            Included in the download is a function handler for evaluating lisp expressions from Excel. It has the following features:
            <ul>
            <li>Uses the open source lisp implementation <a href="http://jatha.sourceforge.net">Jatha</a>.</li>
            <li>Evaluate an lisp expression with the result being returned in excel form (eg. arrays, string, doubles).</li>
            <li>Dynamically add functions to the lisp environment (using defun).</li>
            <li>The server can evaluate a directory of lisp expressions on startup to customise the lisp environment.</li> 
            </ul> 
			</div>
		</div>

        <div class="section">
            <div class="section-title">Excel Example</div>
            The following shows an example of creating a new function called "sum-list", which sums the
            contents of a vector. <br/><br/>
            The first screenshot shows the evaluation of a "defun" statement. The return value is a handle to a function.<br/>
            <img src="lisp1.jpg"/>
            <br/><br/><br/>
            The second screenshot shows the use of the "sum-list" function to sum the contents of a range.<br/>
            <img src="lisp2.jpg"/>
            <br/><br/><br/>
            The third screenshot shows the result.<br/>
            <img src="lisp3.jpg"/>
            <div class="section-content">
			</div>
		</div>
		            
        <div class="section">
            <div class="section-title">Server Code</div>
            <div class="section-content">
            The following code snippet shows how to create a server for the lisp function handler:
<pre>
package org.boris.xlloop;

import java.io.File;

import org.boris.xlloop.script.LispFunctionHandler;
import org.boris.xlloop.util.*;

public class LispTest1 
{
    public static void main(String[] args) throws Exception {
        // Create a new function server on default port
        FunctionServer fs = new FunctionServer();
        
        // Create our lisp function handler
        LispFunctionHandler lfh = new LispFunctionHandler();

        // Evaluate any lisp files in this directory (and sub-dirs)
        lfh.eval(new File("functions"), true); 
        
        // Expose a function called "Eval" for the lisp handler
        FunctionInformationRequestHandler firh = new FunctionInformationRequestHandler();
        firh.add(lfh.getInformation()); 

        // Set the function handler
        fs.setFunctionHandler(new DebugFunctionHandler(lfh));
        
        // Set the request handler (for the function information)
        fs.setRequestHandler(new DebugRequestHandler(firh));
        
        // Run the engine
        fs.run();
    }
}
</pre>
            </div>
        </div>
    </div>
    
    <div id="footer">
		<div class="footer"/>
		<table style="border:0px;width:750px">
		<tr style="border:0px;vertical-align:top">
		<td style="border:0px;vertical-align:top;width:619px">
        <a href="http://www.opensource.org/docs/definition.php"><img border="0" alt="Open Source" src="http://opensource.org/trademarks/open_source_button.png" style="width:88px;height:31px" /></a>
        <a href="http://sourceforge.net"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=222420&amp;type=1" width="88" height="31" border="0" alt="SourceForge.net Logo" /></a>
        </td>
        <td align="right" style="border:0px;vertical-align:top">
        <a href="http://winrun4j.sourceforge.net/"><img border="0" alt="WinRun4J - Configurable Java Launcher for Windows" src="others/winrun4j.gif"/></a>
        <a href="http://xlloop.sourceforge.net/"><img border="0" alt="XLLoop - Excel Functions in Java, Javascript, Ruby, Python, Erlang" src="others/xlloop.gif"/></a>
        <a href="http://variantcodec.sourceforge.net/"><img border="0" alt="VariantCodec - Generic Data Structure Serialization Library for Java" src="others/variantcodec.gif"/></a>
        <a href="http://jvst.sourceforge.net/"><img border="0" alt="JVST - VST Interface for Java" src="others/jvst.gif"/></a>
        <a href="http://jxll.sourceforge.net/"><img border="0" alt="JXLL - Excel Addin Interaction Library" src="others/jxll.gif"/></a>
        <a href="http://expr4j.sourceforge.net/"><img border="0" alt="Expr4J - Expression Calculation Engine for Java" src="others/expr4j.gif"/></a>
        </td>
        </tr>
        </table>
    </div>
</body>
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://apps.sourceforge.net/piwik/xlloop/" : "http://apps.sourceforge.net/piwik/xlloop/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script><script type="text/javascript">
piwik_action_name = '';
piwik_idsite = 1;
piwik_url = pkBaseURL + "piwik.php";
piwik_log(piwik_action_name, piwik_idsite, piwik_url);
</script>
<object><noscript><p><img src="http://apps.sourceforge.net/piwik/xlloop/piwik.php?idsite=1" alt="piwik"/></p></noscript></object>
<!-- End Piwik Tag -->
</html>